package implementor;

import daoInterface.BillDao;
import dbhandeling.Crude;
import dto.Bill;

public class BillImplementor extends Crude implements BillDao
{

String className=new Bill().getClass().getName();

@Override
public void add(Bill bill) throws Exception
{
    insert(bill);
}
/***********************************************************/

@Override
public void update(Bill bill) throws Exception
{
	//super.update(className,"balancePaymentId",bill.getBalancePaymentId()+"","autoBillId",bill.getautoBillId()+"");
super.update(className,"billDate",bill.getbillDate()+"","autoBillId",bill.getautoBillId()+"");
super.update(className,"customerId",bill.getcustomerId()+"","autoBillId",bill.getautoBillId()+"");
}
/***********************************************************/

@Override
public void delete(Bill bill) throws Exception
{
super.delete(className,"autoBillId",bill.getautoBillId()+"");
}
/***********************************************************/

@Override
public Bill retrieve(String conditionField,String conditionValue) throws Exception
{
Bill bill=(Bill) super.retreive(className,conditionField,conditionValue);
return bill;
}
/***********************************************************/


@Override
public Bill[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
Bill[] bill;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
bill=new Bill[obj.length];
for(int i=0;i<bill.length;i++)
{
bill[i]=(Bill) obj[i];
}
return bill;
}
/***********************************************************/

@Override
public Bill[] retrieveAll() throws Exception
{
Bill[] bill;
Object[] obj=super.retreiveAll(className);
bill=new Bill[obj.length];
for(int i=0;i<bill.length;i++)
{
bill[i]=(Bill) obj[i];
}
return bill;
}
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"autoBillId") ;
	 return key;
}
/***********************************************************/

}